/**
 * @author hotab
 */
(function($) {
	$.fn.makeProbModalWindow = function(formId, url, confId){
		$('#'+formId).dialog({modal: true,
			open: function(event, ui) {	jQuery('form[name='+formId+']').validationEngine('attach'); },
			show: 'fade',
			hide: 'fade',
			resizable: false,
			width: 600,
			close: function(event, ui) { jQuery('form[name='+formId+']').validationEngine('hideAll'); },
			buttons: {"Зберегти": function(e){
												if (jQuery('form[name='+formId+']').validationEngine('validate') == true){
													jQuery('form[name='+formId+']').validationEngine('hideAll');
													var arr = $('form[name='+formId+']').serializeArray();
													arr.push( {name: "type", value: confId} );
													$.post(url, arr, function(retData, status){
														if (status == "success"){
															$('#'+formId).dialog("close");
															//window.location.reload("/");
														}
													});
													//$('#'+formId).dialog("close");
												}
									}
					}
		});	
	}
})(jQuery);